<template>
	<view class="bg-white flex flex-direction" style="width: 100vw;height: 100vh;">
		<cu-custom bgColor="bg-white" :isBack="true">
			<block slot="backText">返回</block>
			<block slot="content">
				<text>好物</text>
			</block>
		</cu-custom>
		<view class="flex  align-center justify-center  padding-lr-xl">
			<view @click="switchTab(index)"  v-for="(item,index) in tablist" :key="index" class="flex-sub" style="text-align: center;font-size: 32rpx;font-weight: 600;" :style="[{'color':current==index?'blue':''}]">
				{{item.name}}
			</view>
		</view>
		<!-- 轮播展示 -->
		<swiper class="margin flex-sub" @change="handleChange" :current="current" style="touch-action: none;">
			<!-- 讲书 -->
			<swiper-item >
				<view class="flex margin-bottom-xl"  v-for="(book,index) in goodBooks" :key="index">
				   <bookCell :book="book"></bookCell>
				</view>
			</swiper-item>
			<!-- 课程 -->
			<swiper-item >
				<view class="flex margin-bottom-xl"  v-for="(course,index) in goodCourse" :key="index">
					<singlecell :books="course"></singlecell>
				</view>
			</swiper-item>
		</swiper>

	</view>
</template>

<script>
	import bookCell from '../../components/column/bookCell.vue'
	import singlecell from '../../components/column/singlecell.vue'
	export default {
		components:{
			bookCell,singlecell
		},
		data() {
			return {
				current: 0,
                goodBooks:[],
				goodCourse:[],
				tablist: [{
						name: '讲书'
					},
					{
						name: '课程'
					}
				]
			}
		},
		onLoad(){
	       this.$http.get('/edu/goodlink/getGoodBookList/'+ this.$store.getters.userid).then(res =>{  	
			 this.goodBooks=res.data.result

	       })
		   this.$http.get('/edu/goodlink/getGoodCourseList/'+ this.$store.getters.userid).then(res =>{
		   	  this.goodCourse=res.data.result
			})
		},
		methods:{
			handleChange(e){
				this.current=e.detail.current
				
			},
			switchTab(index){
				this.current=index
				
			}
		}
	}
</script>

<style>
</style>
